package com.five.service.impl;

import com.five.dao.BusinessActivitiesMapper;
import com.five.entity.BusinessActivities;
import com.five.service.BusinessActivitiesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Zero on 2018/2/26.
 */
@Service("IndexService")
public class BusinessActivitiesServiceImpl implements BusinessActivitiesService {

    @Autowired
    private BusinessActivitiesMapper businessActivitiesMapper;


    /**
     * 查找不同类型商家活动信息
     * @param activitiesType
     * @return
     */
    @Override
    public List<BusinessActivities> findBusinessActivitiesByActivitiesType(String activitiesType) {
        return businessActivitiesMapper.selectByActivitiesType(activitiesType);
    }


    /**
     * 添加活动
     * @param businessActivities
     * @return
     */
    @Override
    public int addBusinessActivities(BusinessActivities businessActivities) {
        return businessActivitiesMapper.insertSelective(businessActivities);
    }

    /**
     * 快速参团
     * @param openGroupState
     * @return
     */
    @Override
    public List<BusinessActivities> findNoOpenGroupActivities(Integer openGroupState) {
        return businessActivitiesMapper.selectNoOpenGroupActivities(openGroupState);
    }

    /**
     * 模糊查询活动
     * @param activitiesName
     * @return
     */
    @Override
    public List<BusinessActivities> findActivitiesByName(String activitiesName) {
        return businessActivitiesMapper.selectActivitiesByName(activitiesName);
    }


    /**
     * 查询Id对应活动
     * @param activitiesId
     * @return
     */
    @Override
    public BusinessActivities findActivitiesById(Integer activitiesId) {
        return businessActivitiesMapper.selectByPrimaryKey(activitiesId);
    }


    /**
     * 获得最新信息
     * @param startNumber
     * @param endNumber
     * @return
     */
    @Override
    public List<BusinessActivities> findNewBActivitiesByNumber(Integer startNumber, Integer endNumber) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("startNumber", startNumber);
        params.put("endNumber", endNumber);
        return businessActivitiesMapper.selectNewBActivitiesByNumber(params);
    }

}
